package com.njust.RateMyTray_backend.controller;

import com.njust.RateMyTray_backend.common.Result;
import com.njust.RateMyTray_backend.config.CurrentUser;
import com.njust.RateMyTray_backend.dto.ReportCreateDTO;
import com.njust.RateMyTray_backend.entity.User;
import com.njust.RateMyTray_backend.service.ReportService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@RequestMapping("/api/reports")
public class ReportController {

    @Autowired
    private ReportService reportService;

    @PostMapping
    public Result<Void> createReport(@CurrentUser User currentUser, @RequestBody ReportCreateDTO createDTO) {
        createDTO.setReporterId(currentUser.getId());
        
        log.info("用户 {} 正在提交举报: {}", currentUser.getUsername(), createDTO);
        reportService.createReport(createDTO);
        
        return Result.success(null);
    }
} 